﻿@model FingerPrint.WebUI.Models.SalesOrder

@{
    ViewBag.Title = "Index";  
}

@*<h2>Edit</h2>*@


@using (Html.BeginForm())
{
    <div id="form-SalesOrder1">

    @Html.ValidationSummary(true)

    @Html.HiddenFor(model => model.SalesOrderID)

    
    <fieldset class="editor-fieldset">
        <legend>SalesOrder</legend>
            <div class="row">
                <div class="column1">
    	            <span class="editor-label">Order No.:</span>
                    <span class="editor-textbox">
                        @Html.TextBoxFor(model => model.SalesOrderNumber)
                        @Html.ValidationMessageFor(model => model.SalesOrderNumber)
                    </span>
	            </div>
                <div class="column2">
    	            <span class="editor-label">Company Code:</span>
                    <span class="editor-textbox">
                        @Html.DropDownList("CustomerID", String.Empty)
                        @Html.ValidationMessageFor(model => model.Customer.CompanyCode)
                    </span>
	            </div>
            </div>

            <div class="row">
                <div class="column1">
    	            <span class="editor-label">Received By:</span>
                    <span class="editor-textbox">
                        @Html.DropDownList("EmployeeID", String.Empty)
                        @Html.ValidationMessageFor(model => model.Employee.EngName)
                    </span>
	            </div>
                <div class="column2">
    	            <span class="editor-label">Customer:</span>
                    <span class="editor-textbox">
                        @Html.EditorFor(model => model.CustomerID)
                    </span>
	            </div>
            </div>

            <div class="row">
                <div class="column1">
    	            <span class="editor-label"></span>
                    <span class="editor-textbox"></span>
	            </div>
                <div class="column2">
    	            <span class="editor-label">Tel:</span>
                    <span class="editor-textbox">
                        @Html.EditorFor(model => model.ContactID)
                    </span>
	            </div>
            </div>

            <div class="row">
                <div class="column1">
    	            <span class="editor-label">Order Deadline:</span>
                    <span class="editor-textbox">
                        @Html.EditorFor(model => model.Deadline)
                    </span>
	            </div>
                <div class="column2">
    	            <span class="editor-label">Contact Person:</span>
                    <span class="editor-textbox">
                        @Html.EditorFor(model => model.ContactID)
                    </span>
	            </div>
            </div>

            <div class="row">
                <div class="column">
    	            <span class="editor-label">Invoice No.:</span>
                    <span class="editor-textbox">
                        @Html.EditorFor(model => model.InvoiceNumber)
                    </span>
	            </div>
            </div>

            <div class="row">
                <div class="column">
    	            <span class="editor-label">Remark:</span>
                    <span class="editor-multilinetextbox">
                        @Html.EditorFor(model => model.Remark)
                    </span>
	            </div>
            </div>

            <div class="row">
                <div class="column">
    	            <span class="editor-label">Status:</span>
                    <span class="editor-textbox">
                        @Html.EditorFor(model => model.Status)
                    </span>
	            </div>
            </div>
    </fieldset>
        
    <fieldset class="editor-fieldset">
    <legend>File Information</legend>
        <div class="row">
            <div class="column">
                <span class="editor-label">
                    @Html.LabelFor(model => model.Filename):
                </span>
                <span class="editor-textbox">
                    @Html.EditorFor(model => model.Filename)
                    @Html.ValidationMessageFor(model => model.Filename)
                </span>
            </div>
        </div>

        <div class="row">
            <div class="column">
                <span class="editor-label">Request:</span>
                <span class="editor-checkbox">
                    @Html.CheckBoxFor(model => model.IsNewJob)
                    @Html.LabelFor(model => model.IsNewJob)
                </span>
                <span class="editor-checkbox">
                    @Html.CheckBoxFor(model => model.IsEM)
                    @Html.LabelFor(model => model.IsEM)
                </span>
                <span class="editor-checkbox">
                    @Html.CheckBoxFor(model => model.IsFTP)
                    @Html.LabelFor(model => model.IsFTP)
                </span>
                <span class="editor-checkbox">
                    @Html.CheckBoxFor(model => model.IsDVD)
                    @Html.LabelFor(model => model.IsDVD)
                </span>
            </div>
        </div>

        <div class="row">
            <div class="column">
                <span class="editor-label"></span>
                <span class="editor-checkbox">
                    @Html.CheckBoxFor(model => model.IsMac)
                    @Html.LabelFor(model => model.IsMac)
                </span>
                <span class="editor-checkbox">
                    @Html.CheckBoxFor(model => model.IsPC)
                    @Html.LabelFor(model => model.IsPC)
                </span>
                <span class="editor-checkbox">
                    @Html.CheckBoxFor(model => model.IsTest)
                    @Html.LabelFor(model => model.IsTest)
                </span>
            </div>
        </div>

        <div class="row">
            <div class="column">
                <span class="editor-label">
                    @Html.LabelFor(model => model.Notes):
                </span>
                <span class="editor-multilinetextbox">
                    @Html.EditorFor(model => model.Notes)
                </span>
            </div>
        </div>
	</fieldset>
         
	<fieldset class="editor-fieldset">
    <legend>Quantity & Size</legend>
        <div class="row">
            <div class="column">
                <span class="editor-label">
                    @Html.LabelFor(model => model.Quantity):
                </span>
                <span class="editor-textbox">
                    @Html.EditorFor(model => model.Quantity)
                </span>
            </div>
        </div>

        <div class="row">
            <div class="column">
                <span class="editor-label">
                    @Html.LabelFor(model => model.Size):
                </span>
                <span class="editor-textbox">
                    @Html.EditorFor(model => model.Size)
                </span>
            </div>
        </div>

        <div class="row">
            <div class="column">
                <span class="editor-label">
                    @Html.LabelFor(model => model.Unit):
                </span>
                <span class="editor-textbox">
                    @Html.EditorFor(model => model.Unit)
                </span>
            </div>
        </div>
    </fieldset>
    </div>

    <div id="form-SalesOrder2">
    @(Html.Kendo().TabStrip()
    .Name("tabstrip")
    .Items(items =>
    {
        List<FingerPrint.WebUI.ViewModels.ProductCategoryViewModel> productCategories = ViewBag.ProductCategories;
        
        foreach (var category in productCategories)
        {
            var tabContainer = items.Add().Text(category.Name).Content(TabContainer(category.ProductCategoryID).ToHtmlString());
        }
        
    })
    .SelectedIndex(1))
    

    @helper TabContainer(int productCategoryID)
        {
            
            List<FingerPrint.WebUI.ViewModels.ProductGroupViewModel> productGroups = ViewBag.ProductGroups;            
            List<FingerPrint.WebUI.ViewModels.SelectedSalesOrderProducts> products = ViewBag.Products;
                  
            var groups = productGroups
                    .Where(pg => pg.ProductCategoryID == productCategoryID);
                    
            foreach (var group in groups)
            {  
            <fieldset class="editor-fieldset">    
                <legend>@group.Name</legend>
                <div class="row">
                    <div class="column">

                        @{

                            var productList = products
                                .Where(pc => pc.ProductCategoryID == productCategoryID && pc.ProductGroupID == group.ProductGroupID);

                            foreach (var product in productList)
                            {                
                                    @:<span class="tab-editor-checkbox"> 
                                        <input  type=   "checkbox" 
                                                name=   "@product.ProductID" 
                                                value=  "@product.ProductID" 
                                                        @(Html.Raw(product.Selected ? "checked=\"checked\"" : "")) /> 
                                                        @product.ProductID @:&nbsp; @product.Description
                                    @:</span>
                            }
                            }
                    </div>
                </div>
            </fieldset>
            }

    } 
    </div> 
    
    <p><input type="submit" value="Save" /></p>
    
    <div>
        @Html.ActionLink("Back to List", "Index")
    </div>
    
}

<style>

/* Cusotmised styles */

.editor-fieldset
{
    border:solid 2px #b7ddf2;
    background:#ebf4fb;
    width: 800px;
    margin: 10px 10px 0 0;
}

legend
{
	font-weight: bold;
}
 .row 
{
	width:  auto;
	clear:  both;
	margin: 10px 0 0 0;
}

.column         /*One column per row*/
{
	width:  100%;    
}

.column1        /*Two columns per row. Left column*/
{
    width:  50%;
	float:  left;     
}

.column2        /*Two columns per row. Right column*/
{
    width:  50%;
	float:  right;         
}

 
.editor-label
{
	 float:left;
     display:block;
     font-weight:bold;
     text-align:right;
     width:100px;
     padding: 5px 0 5px 10px;
 }
 
.editor-textbox
{
	float:      left;
	width:      30%;
	padding:    5px 2px 5px 10px;
}


.editor-multilinetextbox
{	float:      left;
	width:      60%;
	padding:    5px 2px 5px 10px;
}


.editor-checkbox 
{
	float:      left;
	width:      15%;
	padding:    5px 2px 5px 10px;
}


.tab-editor-checkbox 
{
	float:      left;
	width:      20%;
	padding:    5px 2px 5px 10px;
}

#form-SalesOrder1 
{
    width:      900px;
}

#form-SalesOrder2 
{
    width:      900px;
    min-height: 500px;

}



</style>
